﻿#ifndef ECGTESTDIALOG_H
#define ECGTESTDIALOG_H
#define dotsPerMM 10.0
#include<heartdata.h>
#include <QDialog>
#include<QPaintEvent>
#include<QPainter>
#include <QColor>
#include"userdata.h"
#include"heartdata.h"
#include"serialtool.h"
namespace Ui {
class ECGTestDialog;
}

class ECGTestDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ECGTestDialog(QWidget *parent = nullptr);
    ~ECGTestDialog();
    void ReadECGFile(QString fileName);
    void getHistoryData();
    void paintEvent(QPaintEvent*event);
    void drawECGGrid(QPainter &painter, int width, int height, double dots);
    void drawHisECGWave(QPainter &painter, int width, int height, double dots);
    void updateECGWave(QPainter &painter, int width, int height, double dots);
    bool serialPortInit();

private slots:
    void on_backButton_clicked();
    void receiveData();

private:
    Ui::ECGTestDialog *ui;
    QJsonArray m_dataArrs;
    HeartData *m_channelData[12];
    SerialTool*m_serial;
    QList<QByteArray>m_newdata;
    bool m_serialflag;
};

#endif // ECGTESTDIALOG_H
